package modele;

import java.io.Serializable;
import java.util.HashMap;

public class Carte extends HashMap<String, Region> implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	public final static Carte carte = new Carte();

	private Carte() {
		this.initMap();
	}

	private void initMap() {
		Region alb = new Region("Albanie", "ALB", false, true, 0, 0, 529, 639); // Grece
		Region ank = new Region("Ankara", "ANK", true, true, 736, 633, 770, 620); // Turquie
		Region apu = new Region("Apulie", "APU", false, true, 0, 0, 471, 635); // Italie
		Region arm = new Region("Arménie", "ARM", false, true, 0, 0, 866, 627); // Turquie
		Region bel = new Region("Belgique", "BEL", true, true, 301, 405, 326, 416); // Belgique
		Region ber = new Region("Berlin", "BER", true, true, 442, 394, 437, 369); // Allemagne
		Region boh = new Region("Bohème", "BOH", false, true, 0, 0, 457, 451); // Cote
																				// de
																				// Munich
		Region bre = new Region("Brest", "BRE", true, true, 213, 431, 242, 457);
		Region bud = new Region("Budapest", "BUD", true, true, 520, 502, 551, 487);
		Region bul = new Region("Bulgarie", "BUL", true, true, 582, 599, 608, 604);
		Region bou = new Region("Bourgogne", "BOU", false, true, 0, 0, 314, 480);
		Region cly = new Region("Clyde", "CLY", false, true, 0, 0, 248, 290); // Angleterre
		Region con = new Region("Constantinople", "CON", true, true, 661, 620, 668, 650);
		Region dan = new Region("Danemark", "DAN", true, true, 431, 329, 403, 311);
		Region edi = new Region("Edimbourg", "EDI", true, true, 268, 286, 272, 257); // Angleterre
		Region esp = new Region("Espagne", "ESP", true, true, 172, 589, 157, 610);
		Region fin = new Region("Finlande", "FIN", false, true, 0, 0, 593, 158);
		Region gal = new Region("Galicie", "GAL", false, true, 0, 0, 576, 458);
		Region gas = new Region("Gascogne", "GAS", false, true, 0, 0, 248, 512);
		Region gre = new Region("Grèce", "GRE", true, true, 581, 688, 556, 650);
		Region hol = new Region("Hollande", "HOL", true, true, 342, 385, 357, 369);
		Region kie = new Region("Kiel", "KIE", true, true, 411, 370, 398, 406);
		Region liv = new Region("Livonie", "LIV", false, true, 0, 0, 593, 340);
		Region lpl = new Region("Liverpool", "LPL", true, true, 256, 338, 262, 310); // Liverpool
		Region lon = new Region("Londres", "LON", true, true, 274, 382, 289, 366);
		Region mar = new Region("Marseille", "MAR", true, true, 313, 557, 318, 523);
		Region mos = new Region("Moscou", "MOS", true, true, 727, 312, 676, 340);
		Region mun = new Region("Munich", "MUN", true, true, 412, 472, 392, 450);
		Region nap = new Region("Naples", "NAP", true, true, 448, 634, 473, 668);
		Region naf = new Region("Afrique du Nord", "NAF", false, true, 0, 0, 208, 725);
		Region nge = new Region("Norvège", "NGE", true, true, 431, 230, 430, 192);
		Region par = new Region("Paris", "PAR", true, true, 290, 445, 271, 472);
		Region pga = new Region("Pays-de-Galle", "PGA", false, true, 0, 0, 242, 355);
		Region pic = new Region("Picardie", "PIR", false, true, 0, 0, 292, 425);
		Region pie = new Region("Piémont", "PIE", false, true, 0, 0, 364, 535);
		Region por = new Region("Portugal", "POR", true, true, 79, 590, 88, 610);
		Region pru = new Region("Prusse", "PRU", false, true, 0, 0, 490, 376);
		Region rom = new Region("Rome", "ROM", true, true, 416, 605, 428, 620);
		Region ruh = new Region("Ruhr", "RUH", false, true, 0, 0, 367, 426);
		Region rou = new Region("Roumanie", "ROU", true, true, 629, 557, 629, 514);
		Region ser = new Region("Serbie", "SER", true, true, 534, 563, 546, 599);
		Region seb = new Region("Sebastopol", "SEB", true, true, 727, 534, 738, 451);
		Region sil = new Region("Silésie", "SIL", false, true, 0, 0, 477, 413);
		Region smy = new Region("Smyrne", "SMY", true, true, 648, 682, 692, 688);
		Region stp = new Region("St Pétersbourg", "STP", true, true, 639, 234, 676, 234);
		Region sue = new Region("Suède", "SUE", true, true, 474, 283, 474, 208);
		Region syr = new Region("Syrie", "SYR", false, true, 0, 0, 847, 724);
		Region tri = new Region("Triestre", "TRI", true, true, 461, 533, 489, 557);
		Region tun = new Region("Tunisie", "TUN", true, true, 358, 718, 353, 737);
		Region tos = new Region("Toscane", "TOS", false, true, 0, 0, 399, 578);
		Region tyr = new Region("Tyrol", "TYR", false, true, 0, 0, 447, 490);
		Region ukr = new Region("Ukraine", "UKR", false, true, 0, 0, 646, 451);
		Region ven = new Region("Venise", "VEN", true, true, 423, 525, 399, 547);
		Region vie = new Region("Vienne", "VIE", true, true, 471, 487, 495, 478);
		Region var = new Region("Varsovie", "VAR", true, true, 539, 404, 562, 394);
		Region yor = new Region("Yorkshire", "YOR", false, true, 0, 0, 278, 344);

		// Ocean
		Region atm = new Region("Atlantique Moyen", "ATM", false, false, 0, 0, 54, 497);
		Region atn = new Region("Atlantique Nord", "ATN", false, false, 0, 0, 78, 218);
		Region hel = new Region("Baie de Heligoland", "HEL", false, false, 0, 0, 361, 339);
		Region bot = new Region("Golfe de Botnie", "BOT", false, false, 0, 0, 532, 252);
		Region gli = new Region("Golfe du Lion", "GLI", false, false, 0, 0, 297, 578);
		Region moc = new Region("Méditerranée Occidentale", "MOC", false, false, 0, 0, 260, 666);
		Region adr = new Region("Mer Adriatique", "ADR", false, false, 0, 0, 451, 588);
		Region bal = new Region("Mer Baltique", "BAL", false, false, 0, 0, 498, 329);
		Region bar = new Region("Mer de Barentz", "BAR", false, false, 0, 0, 668, 31);
		Region ege = new Region("Mer Egée", "EGE", false, false, 0, 0, 616, 709);
		Region ion = new Region("Mer Ionienne", "ION", false, false, 0, 0, 502, 699);
		Region irl = new Region("Mer d'Irlande", "IRL", false, false, 0, 0, 179, 358);
		Region noi = new Region("Mer Noire", "NOI", false, false, 0, 0, 683, 577);
		Region nrd = new Region("Mer du Nord", "NRD", false, false, 0, 0, 339, 262);
		Region nvn = new Region("Mer de Norvège", "NVN", false, false, 0, 0, 354, 147);
		Region mty = new Region("Mer Tyrrhénienne", "MTY", false, false, 0, 0, 391, 651);
		Region man = new Region("Manche", "MAN", false, false, 0, 0, 223, 408);
		Region ska = new Region("Skaggerak", "SKA", false, false, 0, 0, 422, 270);
		Region mor = new Region("Mer du Levant", "MOR", false, false, 0, 0, 697, 737);

		nge.addFrontalier(nvn, bar, stp, fin, sue, nrd, ska);
		noi.addFrontalier(seb, arm, ank, con, bul, rou);
		nrd.addFrontalier(nvn, nge, ska, dan, hel, hol, bel, man, lon, yor, edi);
		seb.addFrontalier(mos, arm, noi, rou, ukr);
		par.addFrontalier(pic, bou, gas, bre);
		hol.addFrontalier(nrd, hel, kie, ruh, bel);
		adr.addFrontalier(ven, tri, alb, ion, apu);
		tyr.addFrontalier(mun, boh, vie, tri, ven, pie);
		ank.addFrontalier(con, noi, arm, smy);
		apu.addFrontalier(ion, ven, nap, rom, adr);
		atm.addFrontalier(atn, irl, man, bre, gas, esp, por, naf, moc);
		bal.addFrontalier(sue, bot, liv, pru, ber, kie, dan, hel);
		bar.addFrontalier(stp, nge, nvn);
		bel.addFrontalier(nrd, hol, ruh, bou, pic, man);
		ber.addFrontalier(bal, pru, sil, mun, kie);
		boh.addFrontalier(sil, gal, vie, tyr, mun);
		bot.addFrontalier(sue, fin, stp, liv, bal);
		bou.addFrontalier(pic, bel, ruh, mun, mar, gas, par);
		bre.addFrontalier(man, pic, par, gas, atm);
		bud.addFrontalier(gal, rou, ser, tri, vie);
		bul.addFrontalier(rou, noi, con, gre, ser, ege);
		arm.addFrontalier(seb, noi, ank, smy, syr);
		con.addFrontalier(bul, noi, ank, smy, ege);
		pga.addFrontalier(irl, lpl, yor, lon, man);
		dan.addFrontalier(ska, kie, hel, nrd, sue);
		edi.addFrontalier(nvn, nrd, yor, lon, man);
		ege.addFrontalier(gre, bul, con, noi, smy, mor, ion);
		esp.addFrontalier(atm, gas, mar, gli, moc, por);
		fin.addFrontalier(nge, stp, bot, sue);
		gal.addFrontalier(var, ukr, rou, bud, vie, boh, sil);
		gas.addFrontalier(bre, par, bou, mar, esp, atm);
		gre.addFrontalier(ser, bul, ege, ion, alb);
		nvn.addFrontalier(nge, nrd, edi, cly, atn, bar);
		hel.addFrontalier(nrd, dan, kie, hol);
		cly.addFrontalier(atn, nvn, edi, lpl);
		ion.addFrontalier(alb, gre, ege, tun, mty, nap, apu, mor);
		atn.addFrontalier(nvn, cly, irl, atm, lpl);
		kie.addFrontalier(dan, bal, ber, mun, ruh, hol, hel);
		mor.addFrontalier(ege, smy, syr, ion);
		gli.addFrontalier(mar, pie, tos, mty, moc, esp);
		liv.addFrontalier(bot, stp, mos, var, pru, bal);
		lpl.addFrontalier(cly, edi, yor, pga, irl, atn);
		lon.addFrontalier(yor, nrd, man, pga);
		man.addFrontalier(irl, pga, lon, nrd, bel, pic, bre, atm);
		naf.addFrontalier(atm, moc, tun);
		moc.addFrontalier(atm, esp, gli, mty, tun, naf);
		alb.addFrontalier(tri, ser, gre, ion, adr);
		mos.addFrontalier(stp, seb, ukr, var, liv);
		mun.addFrontalier(ber, sil, boh, tyr, bou, ruh, kie);
		nap.addFrontalier(rom, apu, ion, mty);
		mar.addFrontalier(bou, pie, gli, esp, gas);
		pic.addFrontalier(man, bel, bou, par, bre);
		pie.addFrontalier(mar, tyr, ven, tos, gli);
		por.addFrontalier(atm, esp);
		pru.addFrontalier(bal, liv, var, sil, ber);
		ruh.addFrontalier(bel, hol, kie, mun, bou);
		rom.addFrontalier(mty, tos, ven, apu, nap);
		rou.addFrontalier(gal, ukr, seb, noi, bul, ser, bud);
		ser.addFrontalier(bud, rou, bul, gre, alb, tri);
		sil.addFrontalier(pru, var, gal, boh, mun, ber);
		smy.addFrontalier(ank, arm, syr, mor, ege, con);
		stp.addFrontalier(bar, mos, liv, bot, fin, nge);
		sue.addFrontalier(nge, fin, bot, bal, ska, dan);
		syr.addFrontalier(smy, arm, mor);
		tos.addFrontalier(pie, ven, rom, mty, gli);
		tri.addFrontalier(vie, bud, ser, alb, adr, ven, tyr);
		tun.addFrontalier(naf, moc, mty, ion);
		ukr.addFrontalier(mos, seb, rou, gal, var);
		ven.addFrontalier(tyr, tri, adr, apu, rom, tos, pie);
		vie.addFrontalier(boh, gal, bud, tri, tyr);
		yor.addFrontalier(edi, nrd, lon, pga, lpl);
		ska.addFrontalier(nge, sue, dan, nrd);
		irl.addFrontalier(atn, lpl, pga, man, atm);
		mty.addFrontalier(gli, tos, rom, nap, ion, tun, moc);
		var.addFrontalier(liv, mos, ukr, gal, sil, pru);

		// HashMap<String, Region> m = new HashMap<String, Region>();

		this.put("nge", nge);
		this.put("noi", noi);
		this.put("nrd", nrd);
		this.put("seb", seb);
		this.put("par", par);
		this.put("hol", hol);
		this.put("adr", adr);
		this.put("tyr", tyr);
		this.put("ank", ank);
		this.put("apu", apu);
		this.put("atm", atm);
		this.put("bal", bal);
		this.put("bar", bar);
		this.put("bel", bel);
		this.put("ber", ber);
		this.put("boh", boh);
		this.put("bot", bot);
		this.put("bou", bou);
		this.put("bre", bre);
		this.put("bud", bud);
		this.put("bul", bul);
		this.put("arm", arm);
		this.put("con", con);
		this.put("pga", pga);
		this.put("dan", dan);
		this.put("edi", edi);
		this.put("ege", ege);
		this.put("esp", esp);
		this.put("fin", fin);
		this.put("gal", gal);
		this.put("gas", gas);
		this.put("gre", gre);
		this.put("nvn", nvn);
		this.put("hel", hel);
		this.put("cly", cly);
		this.put("ion", ion);
		this.put("atn", atn);
		this.put("kie", kie);
		this.put("mor", mor);
		this.put("gli", gli);
		this.put("liv", liv);
		this.put("lpl", lpl);
		this.put("lon", lon);
		this.put("man", man);
		this.put("naf", naf);
		this.put("moc", moc);
		this.put("alb", alb);
		this.put("mos", mos);
		this.put("mun", mun);
		this.put("nap", nap);
		this.put("mar", mar);
		this.put("pic", pic);
		this.put("pie", pie);
		this.put("por", por);
		this.put("pru", pru);
		this.put("ruh", ruh);
		this.put("rom", rom);
		this.put("rou", rou);
		this.put("ser", ser);
		this.put("sil", sil);
		this.put("smy", smy);
		this.put("stp", stp);
		this.put("sue", sue);
		this.put("syr", syr);
		this.put("tos", tos);
		this.put("tri", tri);
		this.put("tun", tun);
		this.put("ukr", ukr);
		this.put("ven", ven);
		this.put("vie", vie);
		this.put("yor", yor);
		this.put("ska", ska);
		this.put("irl", irl);
		this.put("mty", mty);
		this.put("var", var);
	}

	public boolean regionExist(String nomReg) {
		return carte.containsKey(nomReg.toLowerCase());
	}

	public Region getRegion(String nomReg) {
		return carte.get(nomReg.toLowerCase());
	}

	public Region getRegionWithPos(Coordonnee coo) {
		Region res = null;
		for (String mapKey : carte.keySet()) {
			Region region = carte.get(mapKey);
			if (region.getCoordoUnite().equals(coo) || region.getCoordoRavitaillement().equals(coo)) {
				res = region;
				break;
			}
		}
		return res;

	}

}
